POV-Ray : Newsgroups : povray.general : Anyone have a good rusty nail or spike object? : Re: Anyone have a good rusty nail or spike object? Server Time
19 Nov 2024 20:33:40 EST (-0500)
  Re: Anyone have a good rusty nail or spike object?  
From: TinCanMan
Date: 14 Jan 2002 13:07:35
Message: <3c431e67$1@news.povray.org>
Try this macro, it makes a standard type of nail with an optional bend in
it:
Dia=diameter of nail
Len=length of nail
Bend=angle of bend in nail (0=none)
BLen=position of bend from tip of nail

i.e.:  object{Nail(5,50,30,25) material{MyMaterial}}

-tgq

//Start Macro

#macro Nail (Dia,Len,Bend,BLen)
  union{
    union{
      cylinder{0 y 1.5*Dia}
      cylinder{0 -(Len-BLen-1.5*Dia*pi*Bend/360)*y Dia/2}
      torus{0.25 Dia/2 scale<1,0.2,1> translate -2*y}
      torus{0.25 Dia/2 scale<1,0.2,1> translate -3*y}
      torus{0.25 Dia/2 scale<1,0.2,1> translate -4*y}
      translate <-1.5*Dia,Len-BLen-1.5*Dia*pi*Bend/360,0>
      rotate<0,0,-Bend>
      translate <1.5*Dia,BLen,0>
    }
    #if (mod(Bend,360)>0)
      difference{
        torus{1.5*Dia Dia/2 rotate<90,0,0>}
        plane{y 0}
        plane{-y 0 rotate<0,0,-Bend>}
        translate <1.5*Dia,BLen,0>
      }
    #end
    cylinder{<0,3*Dia,0> <0,BLen,0> Dia/2}
    difference{
      cylinder{<0,0,0> <0,3*Dia,0> Dia/2}
      plane{-z 0 rotate <12,  0,0>}
      plane{-z 0 rotate <10, 90,0>}
      plane{-z 0 rotate <12,180,0>}
      plane{-z 0 rotate <10,270,0>}
    }
  }
#end


//End Macro


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.